import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      name: 'Dashboard',
      meta: { title: 'dashboard', icon: 'dashboard', noCache: true, unclosable: true, permission: true }
    }]
  },
  {
    path: '/sys',
    name: 'Sys',
    component: Layout,
    hidden: true,
    redirect: '/sys/role',
    meta: { title: 'sys', icon: 'example' },
    children: [
      {
        path: 'user',
        name: 'User',
        hidden: true,
        component: () => import('@/views/sys/user'),
        meta: { title: 'user', icon: 'user' }
      },
      {
        path: 'role',
        name: 'Role',
        hidden: true,
        component: () => import('@/views/sys/role'),
        meta: { title: 'role', icon: 'user' }
      },
      {
        path: 'permission',
        name: 'Permission',
        hidden: true,
        component: () => import('@/views/sys/permission'),
        meta: { title: 'permission', icon: 'user' }
      },
      {
        path: 'numberRule',
        name: 'NumberRule',
        hidden: true,
        component: () => import('@/views/sys/number-rule'),
        meta: { title: 'numberRule', icon: 'user' }
      }
    ]
  },
  {
    path: '/pickupManage',
    name: 'PickupManage',
    component: Layout,
    hidden: true,
    redirect: '/pickupManage/mimi',
    meta: { title: 'pickupManage', icon: 'example'},
    children: [
      {
        path: 'pickup',
        name: 'Pickup',
        hidden: true,
        component: () => import('@/views/pickupManage/pickup'),
        meta: { title: 'pickup', icon: 'user' }
      },
      {
        path: 'permission',
        name: 'Permission',
        hidden: true,
        component: () => import('@/views/sys/permission'),
        meta: { title: 'permission', icon: 'user' }
      },
      {
        path: 'mimi',
        name: 'Mimi',
        hidden: true,
        component: () => import('@/views/app/mimi'),
        meta: { title: 'mimi', icon: 'user' }
      },
      ]
  },
  {
    path: '/orderManage',
    name: 'OrderManage',
    component: Layout,
    hidden: true,
    redirect: '/orderManage/order',
    meta: { title: 'orderManage', icon: 'tree' },
    children: [
      {
        path: 'order',
        name: 'Order',
        hidden: true,
        component: () => import('@/views/orderManage/order'),
        meta: { title: 'order', icon: 'user' }
      },
      {
        path: 'order1',
        name: 'Order1',
        hidden: true,
        component: () => import('@/views/orderManage/order1'),
        meta: { title: 'order1', icon: 'user' }
      },
      {
        path: 'userRectipt',
        name: 'UserRectipt',
        hidden: true,
        component: () => import('@/views/orderManage/userRectipt'),
        meta: { title: 'userRectipt', icon: 'user' }
      },
      {
        path: 'gameFormulaVerifier',
        name: 'GameFormulaVerifier',
        hidden: true,
        component: () => import('@/views/orderManage/gameFormulaVerifier'),
        meta: { title: 'gameFormulaVerifier', icon: 'user' }
      }
      ]
  },
  {
    path: '/sheet',
    name: 'Sheet',
    component: Layout,
    hidden: true,
    redirect: '/sheet/daily',
    meta: { title: 'sheet', icon: 'table' },
    children: [
      {
        path: 'daily',
        name: 'Daily',
        hidden: true,
        component: () => import('@/views/sheet/dailySheet'),
        meta: { title: 'dailySheet', icon: 'table' }
      },
      {
        path: 'monthly',
        name: 'Monthly',
        hidden: true,
        component: () => import('@/views/sheet/monthlySheet'),
        meta: { title: 'monthlySheet', icon: 'tree' }
      }
    ]
  },
  {
    path: '/form',
    component: Layout,
    name: 'FormRoot',
    hidden: true,
    children: [
      {
        path: 'index',
        name: 'Form',
        hidden: true,
        component: () => import('@/views/form/index'),
        meta: { title: 'form', icon: 'form' }
      }
    ]
  },

  {
    path: '/nested',
    name: 'Nested',
    component: Layout,
    hidden: true,
    redirect: '/nested/menu1',
    meta: {
      title: 'nested',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'menu1',
        hidden: true,
        meta: { title: 'menu1' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'menu1-1',
            hidden: true,
            meta: { title: 'menu1-1' }
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/nested/menu1/menu1-2'),
            name: 'menu1-2',
            hidden: true,
            meta: { title: 'menu1-2' },
            children: [
              {
                path: 'menu1-2-1',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                name: 'menu1-2-1',
                hidden: true,
                meta: { title: 'menu1-2-1' }
              },
              {
                path: 'menu1-2-2',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                name: 'menu1-2-2',
                hidden: true,
                meta: { title: 'menu1-2-2' }
              }
            ]
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'menu1-3',
            hidden: true,
            meta: { title: 'menu1-3' }
          }
        ]
      },
      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'),
        name: 'menu2',
        hidden: true,
        meta: { title: 'menu2' }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

